/**
 * Created by liuchaozhong on 2017/9/1.
 *  dataTabels 插件常用功能的封装
 */

var dataTable_val = null;   //dataTables  对象存储

var DtTatablsConfig = {
    //语言包
    language_zh : function(){
        var option = {
            "oLanguage": {
                "sProcessing": "正在加载中...",
                "sLengthMenu": "每页显示 _MENU_ 条记录",
                "sZeroRecords": "抱歉, 没有匹配的数据",
                "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
                "sInfoEmpty": "没有数据",
                "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
                "sSearch": "搜索",
                "sLengthMenu": "_MENU_ 页/条",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "上一页",
                    "sNext": "下一页",
                    "sLast": "尾页"
                },
                "sZeroRecords": "没有检索到数据"
            }
        };
        return option;
    },
    //配置参数
    config : function($set){
        var option = {
            "serverSide": true,   //开启服务器数据
            "searching": false,    //搜索
            "ordering":  false,   //排序
            "paging": true   ,      //分页功能
            "lengthChange" : true,   //允许用户使用分页改变数量 ↓
            "lengthMenu" : [10,30,50,100],
            "pageLength": 30,    //分页数据条数 默认给30条
            "processing": true    //显示加载提示

        };
        var now_option = $.extend(true, option, $set);
        return now_option;
    }
};

//dataTbales 插件执行方法
function dataTbalesInit(obj, configParams , ajaxParams ){
    var option = $.extend(true, DtTatablsConfig.language_zh(), DtTatablsConfig.config(configParams), ajaxParams );
    //console.log(option); return false;
    dataTable_val = obj.dataTable(option);

}

